#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author   : Moty
# @Time     : 2024/10/18 21:17
# @File     : kc16_1D.py
# @Project  : CSPT
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author   : Moty
# @Time     : 2024/10/18 16:52
# @File     : kc16_1B.py
# @Project  : CSPT
def parse_1D_BMS_Suspend_During_Charging(body):
    # 解析0x1B 错误报文
    data = {
        "交易流水号": f"{body[0:32]}({body[0:32]})",
        "桩编号": f"{body[32:46]}({body[32:46]})",
        "枪号": f"{int(body[46:48], 16)}枪({body[46:48]})",
        "BMS 中止充电原因": f"{bin(int(body[48:50], 16))[2:].zfill(8)}({body[48:50]})",
        "BMS 中止充电故障原因": f"{bin(int(body[50:54], 16))[2:].zfill(8)}({body[50:54]})",
        "BMS 中止充电错误原因": f"{bin(int(body[54:56], 16))[2:].zfill(8)}({body[54:56]})",
    }
    formatted_data = ""
    for key, value in data.items():
        formatted_data += f"{key}: {value}\n"
    return formatted_data


def error_message_type(result):
    return "正常" if result == "00" else "超时" if result == "01" else "不可信" if result == "10" else "未知"


__all__ = ['parse_1D_BMS_Suspend_During_Charging']
